package com.xt.purchasingsystem.controller;


import com.xt.purchasingsystem.dto.ReleaseCargoDto;
import com.xt.purchasingsystem.service.ReleaseCargoService;
import com.xt.purchasingsystem.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 放货登记所有接口
 * </p>
 *
 * @author yhp
 * @since 2020-05-31
 */
@RestController
@RequestMapping("/releaseCargo")
public class ReleaseCargoController {
    @Autowired
    private ReleaseCargoService releaseCargoService;

    /**
     * 添加放货登记及其明细的接口
     * @param releaseCargoDto
     * @return
     */
    @PostMapping
    public Result saveReleaseCargoAndDetails(@RequestBody ReleaseCargoDto releaseCargoDto) {
        return releaseCargoService.saveReleaseCargoAndDetails(releaseCargoDto);
    }


    /**
     * 查询已审核未质检的放货登记
     */
    @GetMapping("getAllReleaseCargo/{currNo}/{pageSize}")
    public Result getAllReleaseCargo(@PathVariable Integer currNo, @PathVariable Integer pageSize){
        return releaseCargoService.qualityInspectionResults(currNo,pageSize);
    }
    /**
     * 分页查询所有未审核的放货登记及其明细的接口
     * @param currNo
     * @param pageSize
     * @return
     */
    @GetMapping("/{currNo}/{pageSize}")
    public Result getAllReleaseCargoAndDetailsIsNoCheck(@PathVariable Integer currNo,@PathVariable Integer pageSize){
        return releaseCargoService.getAllReleaseCargoAndDetailsIsNoCheck(currNo,pageSize);
    }

    @PutMapping
    public Result checkReleaseCargAndDetails(@RequestBody ReleaseCargoDto releaseCargoDto){
        return releaseCargoService.checkReleaseCargAndDetails(releaseCargoDto);
    }
}

